package com.code.observer.strategy;

/**
 * <p>具体的目标对象</p>
 *
 * @author hwf
 * @version 1.0
 * @date 2021/12/8 0:19
 */

public class ConcreateWeatherSubject extends AbstractSubject<StrategyObserve> {

    /**
     * 目标对象状态
     */
    private String weatherContent;

    public String getWeatherContent() {
        return weatherContent;
    }

    public void setWeatherContent(String weatherContent) {
        this.weatherContent = weatherContent;
        this.notifyObserve();
    }

    @Override
    public void notifyObserve() {
        for (StrategyObserve observe : observeList) {
            if ("下雨".equals(this.getWeatherContent())) {
                if ("黄明女朋友".equals(observe.getObserveName()) || "黄明老妈".equals(observe.getObserveName())) {
                    observe.update(this.getWeatherContent());
                }
            } else if ("下雪".equals(this.getWeatherContent())) {
                if ("黄明老妈".equals(observe.getObserveName())) {
                    observe.update(this.getWeatherContent());
                }
            } else {
                System.out.println(weatherContent + ":不通知");
            }
        }
    }
}
